import QRequest from '@/service/index';
import {
    ClassSystemParams,
    ClassSystemResponse,
    EquipmentResponse,
    ClassSystemDetail,
    UpdateClassSystemData
} from './model/type';
import { generateNameToLevel } from '@/config/constant';

/**
 * @description: 班制列表
 * @param {WorkingPeriodParams} params
 * @return {*}
 */
export const doGetClassSystemList = (params: ClassSystemParams) => {
    return QRequest.get<ClassSystemResponse>(`/classSystem`, { params });
};

/**
 * @description: 工作设备列表
 * @param {ClassSystemParams} params
 * @return {*}
 */
export const doGetEquipmentList = (params: ClassSystemParams) => {
    return QRequest.get<EquipmentResponse>(`/classSystem/equipment`, {
        params,
        headers: {
            loadingTarget: `#${generateNameToLevel('1')}`
        }
    });
};

/**
 * @description:查询单条数据班制
 * @param {id: number} params
 * @return {*}
 */
export const doGetClassSystemDetail = (params: { id: number }) => {
    return QRequest.get<ClassSystemDetail>(`/classSystem/detail`, {
        params,
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @description:修改数据班制
 * @param {UpdateClassSystemData} data
 * @return {*}
 */
export const doUpdateClassSystem = (data: UpdateClassSystemData) => {
    return QRequest.put(`/classSystem/update`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @description:添加数据班制
 * @param {UpdateClassSystemData} data
 * @return {*}
 */
export const doAddClassSystem = (data: UpdateClassSystemData) => {
    return QRequest.post(`/classSystem/create`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @description:删除数据班制
 * @param {id: string} params
 * @return {*}
 */
export const doDelClassSystem = (params: { id: number | string }) => {
    return QRequest.delete(`/classSystem/delete`, {
        params,
        headers: {
            hideLoading: 1
        }
    });
};
/**
 * @description:检查班制数据是否处理完成
 * @param {id: string} params
 * @return {*}
 */
export const doGenerateClassSystem = () => {
    return QRequest.get(`/classSystem/generate/working/calendar`, {
        headers: {
            hideLoading: 1
        }
    });
};
